package online.afeibaili.storebackendframework.controller;

import online.afeibaili.storebackendframework.server.GetCouponServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class CouponController {
    @Autowired
    private GetCouponServer getCouponServer;

    @GetMapping("/coupon")
    public ResponseEntity<Map<String, Object>> getCoupon(@RequestParam String userId, @RequestParam long couponId) {
        return ResponseEntity.ok(Map.of("code", 200, "result", getCouponServer.getCoupon(userId, couponId)));
    }
}
